SHELL := /bin/bash
TGZ_VER := 0.$$(date '+%y%m%d.%H%M')+$$(git rev-parse --short HEAD)
CLEAN_VER := $$([[ -z $$(git status -s) ]] || echo '.dirty')
MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
MAKEFILE_FOLDER_PATH := $(subst Makefile,,$(MAKEFILE_PATH))

COLOR_RED := \033[1;31m
COLOR_GREEN := \033[1;32m
COLOR_YELLOW := \033[1;33m
COLOR_RESET := \033[0m

clean:
	@rm -r build

run:
	@./build/main

tgz:
	@echo "###################################################"
	@echo "# Make deb_node"
	@echo "###################################################"
	@echo ""
	@mkdir -p build
	@cd build; \
	cmake .. \
		-DCMAKE_BUILD_TYPE="Release" \
		-DCATKIN_BUILD_BINARY_PACKAGE="1" \
		-DCMAKE_EXPORT_COMPILE_COMMANDS=1 \
		-DMODULE_VERSION="$(TGZ_VER)$(CLEAN_VER)"; \
	make --no-print-directory -j4

debug:
	@echo "###################################################"
	@echo "# Make debug_node"
	@echo "###################################################"
	@echo ""
	@mkdir -p build
	@cd build; \
	cmake .. \
		-DCMAKE_BUILD_TYPE="Debug" \
		-DCATKIN_BUILD_BINARY_PACKAGE="1" \
		-DCMAKE_EXPORT_COMPILE_COMMANDS=1 \
		-DMODULE_VERSION="$(TGZ_VER)$(CLEAN_VER)"; \
	make --no-print-directory -j4
